(function (vc) {
    vc.extends({
        propTypes: {
            emitChooseCouponShopPool: vc.propTypes.string,
            emitLoadData: vc.propTypes.string
        },
        data: {
            chooseCouponShopPoolInfo: {
                couponShopPools: [],
                _currentCouponShopPoolName: '',
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('chooseCouponShopPool', 'openChooseCouponShopPoolModel', function (_param) {
                $('#chooseCouponShopPoolModel').modal('show');
                $that._refreshChooseCouponShopPoolInfo();
                $that._loadAllCouponShopPoolInfo(1, 10, '');
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._loadAllCouponShopPoolInfo(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _loadAllCouponShopPoolInfo: function (_page, _row, _name) {
                var param = {
                    params: {
                        page: _page,
                        row: _row,
                        caId: vc.getCurrentCommunity().caId,
                        shopId: vc.getCurrentCommunity().shopId,
                        couponName: _name
                    }
                };
                //发送get请求
                vc.http.apiGet('couponShopPool.listCouponShopPool',
                    param,
                    function (json) {
                        var _couponShopPoolInfo = JSON.parse(json);
                        $that.chooseCouponShopPoolInfo.couponShopPools = _couponShopPoolInfo.data;
                        vc.emit('pagination', 'init', {
                            total: _couponShopPoolInfo.records,
                            currentPage: _page
                        });
                    }, function () {
                        console.log('请求失败处理');
                    }
                );
            },
            chooseCouponShopPool: function (_couponShopPool) {
                _couponShopPool.couponCount = 1;
                vc.emit($props.emitChooseCouponShopPool, 'chooseCouponShopPool', _couponShopPool);
                $('#chooseCouponShopPoolModel').modal('hide');
            },
            queryCouponShopPools: function () {
                $that._loadAllCouponShopPoolInfo(1, 10, $that.chooseCouponShopPoolInfo._currentCouponShopPoolName);
            },
            _refreshChooseCouponShopPoolInfo: function () {
                $that.chooseCouponShopPoolInfo._currentCouponShopPoolName = "";
            }
        }
    });
})(window.vc);
